﻿using Bean.Entity;
using Bean.Service.IService;
using Microsoft.AspNetCore.Mvc;

namespace Bean.Core.Api.Controllers;

[Route("api")]
[ApiController]
public class TestController : ControllerBase
{
    /// <summary>
    /// </summary>
    private readonly ILogger<TestController> _Logger;

    private readonly IPolicyKeyWordService _PolicyKeyWordService;

    public TestController(ILogger<TestController> logger, IPolicyKeyWordService policyKeyWordService)
    {
        _Logger = logger;

        _PolicyKeyWordService = policyKeyWordService;
    }

    [HttpGet("home")]
    public ActionResult Home()
    {
        //var setKey = RedisHelper.GetSet($"{DateTime.Now:yyyyMMdd}", "1");

        //var getResponse = RedisHelper.Get($"{DateTime.Now:yyyyMMdd}");

        //RedisQueue queue = new RedisQueue("PRO_GJGW_Queue");

        //queue.Send("{\"pushPolicyDelete\":1,\"Id\":6357254508714225,\"ourPolicyId\":8682745522380570,\"flightFareTypeJson\":\"1,2,3,4,16\",\"mark\":\"502,225,894,223,493,201,227,221\",\"dayCondition\":\"1,2,3,4,5,6,7\",\"policyCode\":\"ABCJYCSCZKXFSP-150-CTUPKX\",\"depAirport\":\"TFU\",\"arrAirport\":\"PKX\",\"forbidAirlines\":\"\",\"tripType\":null,\"carrier\":\"QW\",\"officecode\":\"CTU241\",\"patofficecode\":null,\"needPata\":0,\"isneedpnr\":0,\"pnrHandle\":\"禁售\",\"notFlightDate\":null,\"avCount\":5,\"seatLimit\":5,\"saleStartDate\":\"2025-02-17\",\"saleEndDate\":\"2025-02-17\",\"returnPoint\":0.0,\"returnPrice\":-15.0,\"addthreshold\":-0,\"thresholdPointUp\":0.0,\"cabin\":\"Y,P,B,M,H,K,U,A,L,Q,E,V,Z,T\",\"tripStartDate\":\"2025-02-21\",\"tripEndDate\":\"2025-02-21\",\"rtStartDate\":\"\",\"rtEndDate\":\"\",\"minPrice\":1380.0,\"maxPrice\":9999.0,\"minPassenger\":0,\"maxPassenger\":0,\"passengerType\":\"1,2,3\",\"beforeNdays\":2,\"afterNdays\":90,\"lockTime\":0,\"saleTime\":\"0000-0600,0800-2359\",\"flightNumber\":\"\",\"excludeFlightNumber\":\"\",\"policyRemark\":\"CTUPKX-150-2025-02-21\",\"farePrice\":0.0,\"shareShowAct\":1,\"interlineAirlineCode\":\"CZ\",\"flightTimeLimit\":\"0000-2359\",\"saleTimeLimit\":\"0000-0600,0800-2359\",\"purchaserCode\":\"248385\",\"minage\":0,\"maxage\":0,\"policyKeyWord\":\"ABCJYCSCZKXFSP\",\"policyType\":\"PT\",\"saleAvailable\":\"普通人群\",\"shared\":\"是\",\"returnRule\":\"100-2-100\",\"supportCba\":\"否\",\"changeRule\":\"100-2-100\",\"stop\":\"是\",\"xPriceType\":\"个位向上取整\",\"specialRule\":\"1002,1004,1006,1007\",\"status\":\"有效\",\"cardType\":0,\"ticketType\":null,\"cabin2\":\"Y\",\"forbidCabin2\":\"M\",\"flightNoLimit2\":\"所有\",\"shared2\":\"否\",\"dptDateStart2\":\"2025-02-22\",\"dptDateEnd2\":\"2025-02-22\",\"dptDateForbid2\":\"\",\"deptTimeSlot2\":\"\",\"dayCondition2\":\"1,2,3,4,5,6,7\",\"printSource2\":\"公布运价\",\"xPriceType2\":\"十位五舍六入\",\"policyReturnPrice2\":\"-2\",\"printReturnPrice2\":\"-5\",\"printReturnPoint2\":\"0.1\",\"dpt2\":\"PKX\",\"arr2\":\"TFU\",\"policyReturnPoint2\":\"0.1\",\"returnRule2\":\"\",\"changeRule2\":\"\",\"endorsement2\":\"否\",\"beforeTicket2\":5,\"earliestBeforeTicket2\":\"\",\"shortStopTime\":5,\"supportMultiAirports\":\"是\"}");

        //var count = queue.Count;
        //Console.WriteLine(count);
        //var response = queue.Dequeue();
        //Console.WriteLine(response);


        return Ok();
    }


    [HttpGet("home2")]
    public async Task<ApiResponse<IEnumerable<PolicySysRuleDto>>> Home2()
    {
        //var setKey = RedisHelper.GetSet($"{DateTime.Now:yyyyMMdd}", "1");

        //var getResponse = RedisHelper.Get($"{DateTime.Now:yyyyMMdd}");

        //RedisQueue queue = new RedisQueue("PRO_GJGW_Queue");

        //queue.Send("{\"pushPolicyDelete\":1,\"Id\":6357254508714225,\"ourPolicyId\":8682745522380570,\"flightFareTypeJson\":\"1,2,3,4,16\",\"mark\":\"502,225,894,223,493,201,227,221\",\"dayCondition\":\"1,2,3,4,5,6,7\",\"policyCode\":\"ABCJYCSCZKXFSP-150-CTUPKX\",\"depAirport\":\"TFU\",\"arrAirport\":\"PKX\",\"forbidAirlines\":\"\",\"tripType\":null,\"carrier\":\"QW\",\"officecode\":\"CTU241\",\"patofficecode\":null,\"needPata\":0,\"isneedpnr\":0,\"pnrHandle\":\"禁售\",\"notFlightDate\":null,\"avCount\":5,\"seatLimit\":5,\"saleStartDate\":\"2025-02-17\",\"saleEndDate\":\"2025-02-17\",\"returnPoint\":0.0,\"returnPrice\":-15.0,\"addthreshold\":-0,\"thresholdPointUp\":0.0,\"cabin\":\"Y,P,B,M,H,K,U,A,L,Q,E,V,Z,T\",\"tripStartDate\":\"2025-02-21\",\"tripEndDate\":\"2025-02-21\",\"rtStartDate\":\"\",\"rtEndDate\":\"\",\"minPrice\":1380.0,\"maxPrice\":9999.0,\"minPassenger\":0,\"maxPassenger\":0,\"passengerType\":\"1,2,3\",\"beforeNdays\":2,\"afterNdays\":90,\"lockTime\":0,\"saleTime\":\"0000-0600,0800-2359\",\"flightNumber\":\"\",\"excludeFlightNumber\":\"\",\"policyRemark\":\"CTUPKX-150-2025-02-21\",\"farePrice\":0.0,\"shareShowAct\":1,\"interlineAirlineCode\":\"CZ\",\"flightTimeLimit\":\"0000-2359\",\"saleTimeLimit\":\"0000-0600,0800-2359\",\"purchaserCode\":\"248385\",\"minage\":0,\"maxage\":0,\"policyKeyWord\":\"ABCJYCSCZKXFSP\",\"policyType\":\"PT\",\"saleAvailable\":\"普通人群\",\"shared\":\"是\",\"returnRule\":\"100-2-100\",\"supportCba\":\"否\",\"changeRule\":\"100-2-100\",\"stop\":\"是\",\"xPriceType\":\"个位向上取整\",\"specialRule\":\"1002,1004,1006,1007\",\"status\":\"有效\",\"cardType\":0,\"ticketType\":null,\"cabin2\":\"Y\",\"forbidCabin2\":\"M\",\"flightNoLimit2\":\"所有\",\"shared2\":\"否\",\"dptDateStart2\":\"2025-02-22\",\"dptDateEnd2\":\"2025-02-22\",\"dptDateForbid2\":\"\",\"deptTimeSlot2\":\"\",\"dayCondition2\":\"1,2,3,4,5,6,7\",\"printSource2\":\"公布运价\",\"xPriceType2\":\"十位五舍六入\",\"policyReturnPrice2\":\"-2\",\"printReturnPrice2\":\"-5\",\"printReturnPoint2\":\"0.1\",\"dpt2\":\"PKX\",\"arr2\":\"TFU\",\"policyReturnPoint2\":\"0.1\",\"returnRule2\":\"\",\"changeRule2\":\"\",\"endorsement2\":\"否\",\"beforeTicket2\":5,\"earliestBeforeTicket2\":\"\",\"shortStopTime\":5,\"supportMultiAirports\":\"是\"}");

        //var count = queue.Count;
        //Console.WriteLine(count);
        //var response = queue.Dequeue();
        //Console.WriteLine(response);

        var result = await _PolicyKeyWordService.GetListAsync([]);

        _Logger.LogError("测试");
        return ApiResponse<IEnumerable<PolicySysRuleDto>>.Success(result);
    }
}